﻿<%@ Import Namespace="ASPUPLOADLib" %>
<!--#include file="isLogin.aspx"-->
<script language="vbscript" runat="server">
dim isMorethanMaxFileSize
dim boolean_uploadstate

Function SaveFile()
	SaveFile=SaveFileByASPUpload()
End Function

Function SaveFileByASPUpload()
	'on error resume next
	SaveFileByASPUpload=False
	dim mmUpload,File,folderpath,fileNameOnly,fileExName
	dim mmArt = New WebNote.WebNote
	mmUpLoad=Server.CreateObject("Persits.Upload")
	mmUpload.CodePage = 65001
	if MTupload_maxfilesize>0 then
		mmUpLoad.SetMaxSize(MTupload_maxfilesize, True)
	end if
	mmUpLoad.save
	
	File = mmUpLoad.Files(1)
	if File.size>0 then
		folderpath=mmUpLoad.Form("folderpath").Value
		fileExName=Replace(File.Ext,".","")
		
		if mmArt.CheckFileType(allow_upload_file_ext,fileExName) then
			fileNameOnly=mmArt.GetFileNameOnly(File.FileName)
			'fileNameOnly=getAutoName()

			File.SaveAs(server.mappath(folderpath & "/" & fileNameOnly & "." & fileExName))
			SaveFileByASPUpload=True
		end if
	else
		isMorethanMaxFileSize=True
	end if
	File = Nothing
	mmUpLoad=nothing
	mmArt =Nothing
End Function

function getAutoName() as string
	dim a
	Randomize
	a=Now()
	getAutoName=Year(a) & Month(a) & day(a) & Minute(a) & hour(a) & second(a) & Int((99 * Rnd) + 1)
end function
</script>

<%
REM 权限检查
dim mmArtRight As New WebNote.FileRight
	if Not mmArtRight.Upload then
		Response.write("No Right to upload file.")
		Response.end
	end if
mmArtRight=Nothing


isMorethanMaxFileSize=false

boolean_uploadstate=SaveFile()

%>
<script language="javascript" type="text/javascript">
var boolean_uploadstate,isMorethanMaxFileSize;
var Files;
isMorethanMaxFileSize=<%=Lcase(isMorethanMaxFileSize)%>;
boolean_uploadstate=<%=Lcase(boolean_uploadstate)%>;
Files="|";
if (boolean_uploadstate)
{
	window.top.UploadState(0);
}
else
{
	if (isMorethanMaxFileSize)
		window.top.UploadState(1);
	else
		window.top.UploadState(2);

}
</script>